package cmpe226.spring2011.project1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Quote {
    private Date date;
    private double open, high, low, close, adjclose;
    private int volume;
    
	public Quote(String quoteStr) {
	    String[] fields = quoteStr.split(",");
	    
	    try {
            date     = toDate(fields[0]);
            open     = Double.parseDouble(fields[1]);
            high     = Double.parseDouble(fields[2]);
            low      = Double.parseDouble(fields[3]);
            close    = Double.parseDouble(fields[4]);
            volume   = Integer.parseInt(fields[5]);
            adjclose = Double.parseDouble(fields[6]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
	
    public Quote() {
        // Do nothing
    }

    public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public double getOpen() {
		return open;
	}
	public void setOpen(double open) {
		this.open = open;
	}
	public double getHigh() {
		return high;
	}
	public void setHigh(double high) {
		this.high = high;
	}
	public double getLow() {
		return low;
	}
	public void setLow(double low) {
		this.low = low;
	}
	public double getClose() {
		return close;
	}
	public void setClose(double close) {
		this.close = close;
	}
	public double getAdjclose() {
		return adjclose;
	}
	public void setAdjclose(double adjclose) {
		this.adjclose = adjclose;
	}
	public int getVolume() {
		return volume;
	}
	public void setVolume(int volume) {
		this.volume = volume;
	}
	
	private Date toDate(String dateString) throws ParseException {
        return (new SimpleDateFormat("yyyy-MM-dd")).parse(dateString);
    }
}
